<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<% String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";%>
<html>
    <head>
        <base href="<%=basePath%>">
        <script src="/js/jquery.min.js"></script>
        <script type="text/javascript">
            function del() {
                if (confirm("确定要删除吗？\n\n请确认！") == true) {
                    if (confirm("用户信息删除后将无法恢复，确定要删除吗？\n\n请确认！") == true)
                        return true;
                }
                return false;
            };
            $(function () {
                //新建
                $("#new").click(function () {
                    window.location.href = "admin/order/orderAdd.jsp";
                })
                //查询
                $("#search").click(function () {
                    window.location.href = "admin/order/orderSearch.jsp";
                })
            });
        </script>
    </head>
    <body>
        <jsp:include page="/admin/top.jsp"/>
        <!-- 表头 -------------------------------------------------------------------->
        <div class="middle listbox">
            <button id="new">新建</button>
            <button id="search">查询</button>
        </div>
        <!-- 表头 --------------------------------------------------------------------->
        <div class="middle" style="height:300px">
            <table class="middle list">
                <thead>
                    <tr>
                        <th width=5%>序号</th>
                        <th width="10%">订单编号</th>
                        <th width="10%">订单日期</th>
                        <th width="5%">订单总数</th>
                        <th width="5%">订单价格</th>
                        <th width="5%">支付方式</th>
                        <th width="5%">订单快递</th>
                        <th width="10%">订单接收人</th>
                        <th width="15%">地址</th>
                        <th width="10%">电话</th>
                        <th width="10%">邮政编码</th>
                        <th width="5%">状态</th>
                        <th width="5%">操作</th>
                    </tr>
                </thead>
                <tbody>
                <c:set var="i" value="${(page.pageNum-1)*page.pageSize}"/>
                <c:forEach items="${list}" var="order">
                    <tr>
                        <td width="5%">
                            <c:set var="i" value="${i+1 }"/>
                            <c:out value="${i}"/>
                        </td>
                        <td width="10%">
                            <a href="order/orderInfo?orderId=${order.orderid}">${order.orderid}</a>
                        </td>
                            <%--<td width="10%">${order.orderdate}</td>--%>
                        <td width="10%"><fmt:formatDate value="${order.orderdate}" pattern="yyyy-MM-dd"/></td>
                        <td width="5%">${order.totalnum}</td>
                        <td width="5%">${order.totalamount}</td>
                        <td width="5%">${order.payment}</td>
                        <td width="5%">${order.deliver}</td>
                        <td width="10%">${order.receiver}</td>
                        <td width="15%">${order.address}</td>
                        <td width="10%">${order.phone}</td>
                        <td width="10%">${order.postcode}</td>
                        <td width="5%">
                            <c:choose>
                                <c:when test="${order.state==1}">激活</c:when>
                                <c:when test="${order.state==0}">未激活</c:when>
                            </c:choose>
                        </td>
                        <td width="5%">
                            <a href="order/orderDel?op=del&orderId=${order.orderid}" onclick="return del();">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <!-- 页码 --------------------------------------------------------------->
        <div class="middle listbox">
            共${page.pages}页 &nbsp;
            <c:forEach begin="1" end="${page.pages}" var="i">
                <c:choose>
                    <c:when test="${page.pageNum==i}"><span style="font-weight: bold">${i}</span></c:when>
                    <c:when test="${page.pageNum!=i}"><a href="order/orderList?pageNum=${i}">
                        <span style="font-weight: bold;text-decoration: underline">${i}</span>
                    </a></c:when>
                </c:choose>
            </c:forEach>
        </div>
        <!-- 页码 ---------------------------------------------------------------->
        <jsp:include page="/admin/bottom.jsp"/>
    </body>
</html>